package com.hisan.freeride.home.activity;

import android.database.Cursor;
import android.os.Bundle;

import com.hisan.freeride.R;
import com.hisan.freeride.common.base.BaseActivity;
import com.hisan.freeride.common.base.BaseAppLication;
import com.hisan.freeride.common.utils.CacheUtils;


/**
 * 应用启动页
 * Created by Administrator on 2017/2/23.
 */

public class AppSwitch extends BaseActivity {
    private String city="";
    private int id=0;

    @Override
    protected int getLayoutId() {
        return R.layout.myswitch;
    }

    @Override
    protected void initView() {
        int c= BaseAppLication.getInstance().getCityManger().queryAllUser().getCount();
        if (c>0){
            Cursor cursor=BaseAppLication.getInstance().getCityManger().queryAllUser();
            while (cursor.moveToNext()) {
                id= cursor.getInt(cursor.getColumnIndex("id"));
                city= cursor.getString(cursor.getColumnIndex("city"));
            }
            BaseAppLication.getInstance().getCityManger().close();
            BaseAppLication.getInstance().setCityid(id);
            Bundle bundle=new Bundle();
            bundle.putString("city",city);
            bundle.putInt("id",id);
            startActivityForResult(MainActivity.class,0,bundle,true);
            finishActivity(true);
        }else {
            Bundle bundle=new Bundle();
            bundle.putString("name","首页");
            startActivityForResult(Select_CityActivity.class,0,bundle,true);
            finishActivity(true);
        }
    }

    @Override
    protected void initEvent() {}
    @Override
    protected void loadData(boolean isRefresh) {}


}
